﻿using System;


namespace FireBus.Contracts
{
	public class SendEventArgs<TRequest, TResponse> : EventArgs
		where TRequest : class
		where TResponse : class
	{
		private readonly ExtensionName _Listener;

		private readonly TRequest _Request;

		private readonly ExtensionResponseCollection<TResponse> _Responses
			= new ExtensionResponseCollection<TResponse>();

		private readonly Boolean _IsMulticast;


		public ExtensionName Listener
		{
			get { return _Listener; }
		}
		
		public TRequest Request
		{
			get { return _Request; }
		}

		public ExtensionResponseCollection<TResponse> Responses
		{
			get { return _Responses; }
		}

		public Boolean IsMulticast
		{
			get { return _IsMulticast; }
		}


		public SendEventArgs(TRequest request, Boolean isMulticast)
		{
			if (request == null)
			{
				throw new ArgumentNullException("request");
			}
			_Request = request;
			_IsMulticast = isMulticast;
		}

		public SendEventArgs(ExtensionName listener, TRequest request)
			: this(request, false)
		{
			if (listener == null)
			{
				throw new ArgumentNullException("listener");
			}
			_Listener = listener;
		}
	}
}
